package io.SerializableDemo;

import java.io.*;

//证明为啥需要为每个序列化的对象增加一个序列化ID
public class SerializableID {

    public static void main(String[] args) throws IOException {
        Person student = new Person("学生", 23);
        Teacher teacher1 = new Teacher("大老师",student);
        Teacher teacher2 = new Teacher("小老师",student);

        ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream("SerializableID.txt"));
        objectOutputStream.writeObject(teacher1);
        objectOutputStream.writeObject(teacher2);
        objectOutputStream.writeObject(student);

        objectOutputStream.close();



    }
}
